Skip to content

fix(#1931): show user-friendly warning when answerOption terminology lookup fails - #2000

Open
MaryamMehd wants to merge 6 commits into
mainfrom
issue/1931-answer-option-lookup-failure
Open

fix(#1931): show user-friendly warning when answerOption terminology lookup fails#2000
MaryamMehd wants to merge 6 commits into
mainfrom
issue/1931-answer-option-lookup-failure

Conversation

@MaryamMehd

@MaryamMehd MaryamMehd commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1931

When a questionnaire has answerOption codings without display values, the renderer calls CodeSystem/$lookup to fetch human-readable labels. If the terminology server is unavailable, the lookups silently fail and the UI displays raw SNOMED codes — confusing for end users.

Changes:

  • addDisplayToAnswerOptions now returns a lookupFailedCodingKeys: Set<string> (keyed by system|code) alongside the resolved options, tracking failed lookups at the individual coding level.
  • answerOptionsLookupFailures is threaded through QuestionnaireModel, QuestionnaireStoreType, and useQuestionnaireStore so field components can detect which specific options could not be resolved.
  • ChoiceSelectAnswerOptionFields and OpenChoiceSelectAnswerOptionField now filter out unresolvable options from the dropdown (so no raw codes are shown) and display an amber helper text: "Some items in this list were not able to be displayed".
  • Unit tests in addDisplayToCodings.test.ts updated to assert lookupFailedCodingKeys is correctly populated.

Before / After

Scenario Dropdown behaviour
Working terminology server Human-readable labels as normal ✅
Server unavailable — before fix Raw SNOMED codes (133932002, 394738000) shown in dropdown ❌
Server unavailable — after fix Unresolvable options hidden; amber warning: "Some items in this list were not able to be displayed" ✅

Test plan

  • Run unit tests: cd packages/smart-forms-renderer && npx jest --testPathPattern="addDisplayToCodings" — all tests pass.
  • In the Playground, load a questionnaire with answerOption codings that have no display, set the terminology server to a URL that validates but lacks SNOMED (e.g. https://hapi.fhir.org/baseR4), build the form — affected options are hidden and the amber warning appears.
  • With a working terminology server, the dropdown shows proper labels with no warning.

MARYAMMEHDIZ and others added 5 commits July 10, 2026 14:29
… codes (issue #1931)

Co-authored-by: Cursor <cursoragent@cursor.com>
… error

Co-authored-by: Cursor <cursoragent@cursor.com>
)

Co-authored-by: Cursor <cursoragent@cursor.com>
…sue #1931)

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@MaryamMehd
MaryamMehd requested a review from leoniedickson July 10, 2026 07:58
…linkId

Switch answerOptionsLookupFailures from tracking linkIds to individual
coding keys (system|code). The dropdown now stays accessible and shows
a bracketed code fallback (e.g. [133932002]) for each option that could
not be resolved, with a single amber warning below the field for partial
failures — keeping successfully-resolved options fully labelled.

Co-authored-by: Cursor <cursoragent@cursor.com>
@MaryamMehd MaryamMehd changed the title fix: show error alert when answerOption $lookup fails instead of displaying raw codes (issue #1931) fix(#1931): show user-friendly warning when answerOption terminology lookup fails Jul 20, 2026
@MaryamMehd
MaryamMehd marked this pull request as ready for review July 20, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

answerOption list being displayed is a list of codes when $lookup fails

2 participants